/**
 *
 */

package org.platform.tool.util;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;

/**
 * @author mabb
 */
public class MyFileUtils {
    /**
     * 把收到的文件拷贝到目标目录
     * 
     * @param srcFullFileName
     * @param dstFileDir
     */
    public static void copyFile(String srcFullFileName, String dstFileDir) {
	File srcFile = new File(srcFullFileName);
	File destFile = new File(dstFileDir);

	try {
	    FileUtils.copyFile(srcFile, destFile);
	} catch (IOException e) {
	}

    }

    /**
     * 在指定目录写入文件
     * 
     * @param cmdCode
     * @param taskCode
     * @param dstFileDir
     * @param txtMsg
     */
    public static void createFile(String cmdCode, String taskCode, String dstFileDir, String txtMsg) {
	try {

	    String dstFileName = StringUtils.join(dstFileDir, File.separator, cmdCode, "_", taskCode, ".txt");
	    File dstFile = new File(dstFileName);
	    FileUtils.writeStringToFile(dstFile, txtMsg, Charset.forName("UTF-8"));
	} catch (Exception e) {
	}
    }
}
